package com.bloveoacom.weichi.presenter;


import com.bloveoacom.http.RxHelper;
import com.bloveoacom.observer.BaseListSubscriber2;
import com.bloveoacom.weichi.bean.PostCoinBean;
import com.bloveoacom.weichi.contract.PostListContract;

import static com.bloveoacom.http.HttpMethods.PAGE_START_SIZE;

/**
 * author: zhu.px
 * e-mail: 1271901673@qq.com
 * time  : 2018/8/22
 * desc  : 我的
 */
public class PostListPresenter extends PostListContract.Presenter {


    @Override
    public void loadFirstData(boolean isRefresh) {
        pageIndex = PAGE_START_SIZE;
        BaseListSubscriber2<PostCoinBean> postCoinBeanFlowable = mModel.getCoinNewsList(pageIndex, mView.getPageSize(), mView.getSort()).compose(RxHelper.<PostCoinBean>io_main()).subscribeWith(new BaseListSubscriber2<PostCoinBean>(mView,isRefresh,pageIndex){
            @Override
            public void onNext(PostCoinBean o) {
                 mView.getSuccess(o);
                 pageIndex++;
            }
        });
        addDispose(postCoinBeanFlowable);
    }

    @Override
    public void loadMoreData() {
        BaseListSubscriber2<PostCoinBean> postCoinBeanFlowable = mModel.getCoinNewsList(pageIndex, mView.getPageSize(), mView.getSort()).compose(RxHelper.<PostCoinBean>io_main()).subscribeWith(new BaseListSubscriber2<PostCoinBean>(mView,false,pageIndex){
            @Override
            public void onNext(PostCoinBean o) {
                mView.getSuccess(o);
                pageIndex++;
            }
        });
        addDispose(postCoinBeanFlowable);
    }
}
